﻿using System;
using System.Collections.Generic;

namespace Pixels.Logic.Structures
{
    class ConstructionSite : Structure {

        public StructureType eventualType;

        public void assign(StructureType type) {
            this.eventualType = type;
            this.totalConstructionTime = GlobalConsts.getStructureConsts(eventualType).constructionTime;
        }

        internal override string getName() {
            return "Construction Site : " + eventualType.ToString();
        }

        public int totalConstructionTime = 1;
        public int constructionProgress = 0; // when this is equal to ConstructionTime it's complete

        internal override void calculateEffects() { // upon end of turn

            var builders = this.countAssignedColonists(Colonist.Occupation.technician);
            constructionProgress += builders;
            if (constructionProgress > totalConstructionTime) {
                gameplayEffect.addEvent(new GameplayEvents.ConstructionCompleteEvent(this));
            }
        }

        protected override bool isColonistTypeAssignable(Colonist.Occupation occupation) {
            return occupation == Colonist.Occupation.technician;
        }

        internal override int maxSlots() { return 3; }
    }
}
